//
//  TCLYTopUpViewController.m
//  YuErmuYing
//
//  Created by LYang on 16/9/26.
//  Copyright © 2016年 Tiancheng. All rights reserved.
//

#import "TCLYTopUpViewController.h"
#import "Macros.h"
#import "Masonry.h"

@interface TCLYTopUpViewController ()
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *bgViewHeight;
@property (weak, nonatomic) IBOutlet UIScrollView *bgScrollView;
@property (weak, nonatomic) IBOutlet UIView *bgView;
@property (weak, nonatomic) IBOutlet UIImageView *wechatImageView;
@property (weak, nonatomic) IBOutlet UIButton *wechatBtn;
@property (weak, nonatomic) IBOutlet UIImageView *alipayImageView;
@property (weak, nonatomic) IBOutlet UIButton *alipayBtn;
@property (weak, nonatomic) IBOutlet UITextField *moneyTextField;
@property (weak, nonatomic) IBOutlet UIView *wechatView;
@property (weak, nonatomic) IBOutlet UIView *alipayView;
@property (weak, nonatomic) IBOutlet UIView *moneyView;
@property (weak, nonatomic) IBOutlet UIButton *determineBtn;


@end

@implementation TCLYTopUpViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.view.backgroundColor = bgColor;
    self.bgView.backgroundColor = bgColor;
    UITapGestureRecognizer * wechatTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(walletTapAction)];
    [self.wechatView addGestureRecognizer:wechatTap];
    UITapGestureRecognizer * alipayTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(alipayTapAction)];
    [self.alipayView addGestureRecognizer:alipayTap];
    
    UITapGestureRecognizer * textFeildTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissKeyboard)];
    [self.view addGestureRecognizer:textFeildTap];
    
    [self createView];
    [self createTitleView];
}
-(void)createView{
    self.wechatImageView.image = [UIImage imageNamed:@"wechat"];
    self.alipayImageView.image = [UIImage imageNamed:@"Alipay"];
    [self.wechatBtn setImage:[UIImage imageNamed:@"mineTic"] forState:UIControlStateNormal];
    [self.alipayBtn setImage:[UIImage imageNamed:@"mineTic"] forState:UIControlStateNormal];
    
    [self.wechatBtn setImage:[UIImage imageNamed:@"mineTick-click"] forState:UIControlStateSelected];
    [self.alipayBtn setImage:[UIImage imageNamed:@"mineTick-click"] forState:UIControlStateSelected];
    self.wechatBtn.selected = YES;
    
    [self.determineBtn setTitle:@"充值" forState:UIControlStateNormal];
    [self.determineBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    self.determineBtn.backgroundColor = btnColor;
    self.determineBtn.layer.cornerRadius = 5;
    self.determineBtn.layer.masksToBounds = YES;
    
    
}
-(IBAction)determineBtnAction:(id)sender{
    
}
-(void)walletTapAction{
    self.wechatBtn.selected = YES;
    self.alipayBtn.selected = NO;
}
-(void)alipayTapAction{
    self.wechatBtn.selected = NO;
    self.alipayBtn.selected = YES;
    
}
-(void)createTitleView{
    self.navigationController.navigationBar.barStyle = UIBarMetricsCompactPrompt;
    self.navigationController.navigationBar.backgroundColor = statusColor;
    UIView * view = [[UIView alloc] initWithFrame:CGRectMake(0, -20, screenWidth, 20)];
    view.backgroundColor = navColor;
    [self.navigationController.navigationBar addSubview:view];
    
    UILabel * titleLabel = [[UILabel alloc] init];
    titleLabel.text = @"提现";
    titleLabel.textColor = [UIColor whiteColor];
    titleLabel.frame = CGRectMake(0, 0, 50, 20);
    titleLabel.font = [UIFont boldSystemFontOfSize:20];
    self.navigationItem.titleView = titleLabel;
    
    UIButton * leftBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    leftBtn.frame = CGRectMake(12, 22, 20, 20);
    [leftBtn setImage:[UIImage imageNamed:@"left"] forState:UIControlStateNormal];
    leftBtn.tag = 91;
    [leftBtn addTarget:self action:@selector(statusBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftBtn];
}
-(void)statusBtnAction:(id)sender{
    switch (((UIButton *)sender).tag) {
        case 91:{
            [self.navigationController popViewControllerAnimated:YES];
            self.navigationController.navigationBarHidden = NO;
            self.tabBarController.tabBar.hidden = YES;
        }
            break;
        case 92:{
            
        }
            break;
    }
}
-(void)dismissKeyboard{
    [self.moneyTextField resignFirstResponder];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
